<template>
	<view class="forgetPassword">
		
		<u-navbar  title=""  :border-bottom="false"  >
		</u-navbar>
		<view class="forgetPassword__block">
			<view class="forgetPassword__block__title">重置密码</view>
			<view class="form">
			
			<u-field 
				class="forgetPassword__block__input" 
				v-model="password" 
				placeholder="密码" 
				:label-width="0" 
				:password="true"
				:clearable="false">
			</u-field>
			<u-field 
				class="forgetPassword__block__input" 
				v-model="confirmPassword" 
				placeholder="确认密码" 
				:label-width="0" 
				:password="true"
				:clearable="false"
				>
			</u-field>
			<u-button class="forgetPassword__block__button" type="primary" @click="forgetPassword()">重置密码</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import  axios from "axios";
	import store from './store.js'
	export default {

		data() {
			return {
				store:store,
				passwordIcon:true,
				password: '',
				confirmPassword:"",

				agree:true,

			}
		},
		onLoad() {
			
		},
		onLoad() {

		},
		mounted(){

		},
		methods: {
			goback(){
				uni.navigateBack();
			},
			getCountry(){
				uni.navigateTo({
					url:"/pages/login/chooseCountry"
				})
			},
			forgetPassword(){
				console.log("getPassword")
				let forgetPasswordData={
					phone:this.store.state.phone,
					newPassword:this.password,
					newConfirmPassword:this.confirmPassword,
					code:this.store.state.phonecode,
				}
				axios({
					method:"post",
					url:this.$store.state.baseURL+"/user/password/forget",
					data:forgetPasswordData,
				}).then((response)=>{
					console.log("response",response)
					if(response.data.state=="Success"){
						uni.showToast({
							title:"重置密码成功，请登录",
							icon:"none",
							duration:2000
						})
						setTimeout(function(){
							uni.navigateTo({
								url:"/pages/login/login"
							})
						},2000)

					}else{
						uni.showToast({
							title:response.data.msg,
							icon:"none",
							duration:2000
						})
					}
				})
			}
		
		}
	}
</script>
<style lang="scss" scoped>
	a {
		color: $uni-text-color-placeholder;
	}
</style>
<style lang="less" scoped>
	.forgetPassword{
		display: flex;
		flex-direction: column;
		align-items: center;
		&__block {
		
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: flex-start;
		&__title{
			align-self: flex-start;
			font-size: x-large;
			// font-weight: bold;
			margin: @uni-spacing-row-sm @uni-spacing-col-lg 0 @uni-spacing-col-lg ;
		}
		
		.form {
			}
			&__input {
				margin:@uni-spacing-row-sm @uni-spacing-col-lg  0  @uni-spacing-col-lg ;
				&__countryCode{
					margin-right: @uni-spacing-col-sm ;
					display: flex;
					align-items: center;
					&__border-right{
						margin-left: @uni-spacing-col-base;
						background-color: @uni-border-color;
						width: 1px;
						height: 10px;
					}
				}
				&__button{
					// background-color: #e2e2e2;
					font-size: small;
					color: @font-color-blue;
					&__disabled{
						color: @uni-text-color-grey;
						cursor: not-allowed;
					}
				}

			}
			&__button {
				margin-top: @uni-spacing-row-lg;
				margin-left: @uni-spacing-col-lg;
				margin-right: @uni-spacing-col-lg;
			}
		// }
	}
	}
</style>
